package emulator.util.file;

import java.io.FileInputStream;
import java.io.IOException;

import emulator.hardware.memory.MemoryBlockInterface;
import emulator.shell.DebugShell;

public class FileLoadStrategyRaw implements FileLoadStrategy {

	@Override
	public void loadToMemory(String file_name, MemoryBlockInterface memory,
								int start_address, int block_size)
	{
		FileInputStream file = null;
		try
		{
			file = new FileInputStream(file_name);
			memory.loadFromStream(file, start_address, block_size);
		}
		catch (IOException e)
		{
			DebugShell.getInstance().getErr().println("File read failed for \""+file_name+"\" (raw): "+e.getMessage());
		}
		finally
		{
			if (file != null)
				try { file.close(); } catch (IOException e) {}
		}
	}
}
